package com.yanqu.road.server.cmd.activity.peakseacraft.cross;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.seacraft.config.SeacraftSouthSeaActivityConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.entity.player.UserPatrons;
import com.yanqu.road.entity.union.UnionBaseInfo;
import com.yanqu.road.entity.union.cross.CrossUnionInfo;
import com.yanqu.road.entity.union.cross.CrossUnionMember;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.logic.pb.UnionBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakSeacraftProto;
import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.peakseacraft.PeakSeacraftModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.peakseacraft.PeakSeacraftMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.utils.string.StringUtils;
import io.netty.channel.ChannelHandlerContext;

import java.util.List;
import java.util.Map;

@Cmd(code = GameProtocol.S_PEAK_SEACRAFT_LOCK_JOIN_UNION_FROM_CROSS, desc = "锁定晋级名单 跨服返回区服 协议")
public class PeakSeacraftLockJoinUnionFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        PeakSeacraftProto.PeakSeacraftSynPromotionUnionCrossToGameMsg crossToGameMsg = PeakSeacraftProto.PeakSeacraftSynPromotionUnionCrossToGameMsg.parseFrom(packet.getBytes());
        if(!CrossUnionMgr.isAllSync()){
            return;
        }
        ActivityInfo activityInfo = ActivityMgr.getOpenActivityInfo(crossToGameMsg.getActivityId());
        if (null == activityInfo){
            return;
        }
        if (activityInfo.getType() == eActivityType.PeakSeacraftActivity.getValue()) {
            PeakSeacraftMgr.lockJoinUnionFromCross(crossToGameMsg);
        }
    }
}
